package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/schema/edge"
	"entgo.io/ent/schema/field"
	"time"
)

type User struct {
	ent.Schema
}

func (User) Fields() []ent.Field {
	return []ent.Field{
		field.Int("id"),
		field.String("phone").Default(""),
		field.String("nickname").Default(""),
		field.Int("level").Default(0),
		field.Int("category").Default(0),
		field.Time("vip_start_time").Nillable().Default(nil),
		field.Time("vip_end_time").Nillable().Default(nil),
		field.Int("vip_resource_download_times").Default(0),
		field.Time("create_time").Default(time.Now),
		field.Time("update_time").Default(time.Now).UpdateDefault(time.Now),
	}
}

func (User) Edges() []ent.Edge {
	return []ent.Edge{
		edge.To("articleOrders", ArticleOrder.Type),
		edge.To("articles", Article.Type),
	}
}
